/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package BLO;

import DAO.StudentDAO;
import java.sql.Connection;
import java.util.ArrayList;
import DTO.StudentDTO;
import Util.ConnectionUtil;
/**
 *
 * @author Arturia
 */
public class StudentBLO {
    private Connection con;

    public ArrayList<StudentDTO> getAllStudents() {
        ArrayList<StudentDTO> list = new ArrayList<StudentDTO>();
        try {
            con = ConnectionUtil.getConnection();
            list = StudentDAO.LoadDatabase(con, null);

        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }

    public boolean insertStudent(StudentDTO person){
        con = ConnectionUtil.getConnection();
        if (StudentDAO.insert(con, person) > 0) {
            return true;
        }
        return false;
    }

    public boolean updateStudent(StudentDTO person){
        con = ConnectionUtil.getConnection();
        if (StudentDAO.update(con, person) > 0) {
            return true;
        }
        return false;
    }

    public boolean deleteStudent(String deleteStudent){
        con = ConnectionUtil.getConnection();
        if(StudentDAO.delete(con, deleteStudent) > 0){
            return true;
        }
        return false;
    }
}
